home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP09.ZIP / CHAP09 / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-06-23  |  10KB  |  314 lines

  1. /*
  2.  * PAGES.H
  3.  * Modifications for Chapter 9
  4.  *
  5.  * Definitions and function prototypes for the Pages window control
  6.  * as well as the CPage class.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PAGES_H_
  19. #define _PAGES_H_
  20.  
  21. //We need this for UICursorLoad and new-style cursors.
  22. #include <bttncur.h>
  23.  
  24.  
  25. //Versioning.
  26. #define VERSIONMAJOR                2
  27. #define VERSIONMINOR                0
  28. #define VERSIONCURRENT              0x00020000
  29.  
  30. //Classname
  31. #define SZCLASSPAGES                "pages"
  32.  
  33. #define HIMETRIC_PER_INCH           2540
  34. #define LOMETRIC_PER_INCH           254
  35. #define LOMETRIC_BORDER             60          //Border around page
  36.  
  37.  
  38. //Window extra bytes and offsets
  39. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  40. #define PAGEWL_STRUCTURE            0
  41.  
  42.  
  43. //CHAPTER9MOD
  44. //Time to break this stuff out into another file.
  45. #include "tenant.h"
  46. //End CHAPTER9MOD
  47.  
  48.  
  49. typedef struct __far tagTENANTLIST
  50.     {
  51.     DWORD       cTenants;
  52.     DWORD       dwIDNext;
  53.     } TENANTLIST, FAR *LPTENANTLIST;
  54.  
  55.  
  56. /*
  57.  * Persistent information we need to save for each tenant, which is done
  58.  * in the tenant list instead of with each tenant.  Since this is a small
  59.  * structure it's best not to blow another stream for it (overhead).
  60.  */
  61. typedef struct tagTENANTINFO
  62.     {
  63.     DWORD       dwID;
  64.     RECTL       rcl;
  65.     FORMATETC   fe;     //Excludes ptd
  66.     } TENANTINFO, FAR *LPTENANTINFO;
  67.  
  68.  
  69. #define SZSTREAMTENANTLIST        "Tenant List"
  70.  
  71.  
  72.  
  73.  
  74. /*
  75.  * Page class describing an individual page and what things it contains,
  76.  * managing an IStorage for us.
  77.  *
  78.  * A DWORD is used to identify this page as the name of the storage
  79.  * is the string form of this ID.  If we added a page every second,
  80.  * it would take 136 years to overrun this counter, so we can
  81.  * get away with saving it persistently.  I hope this software is
  82.  * obsolete by then.
  83.  */
  84.  
  85. class __far CPage
  86.     {
  87.     private:
  88.         HWND        m_hWnd;             //Pages window, same as CPages.
  89.         DWORD       m_dwID;             //Persistent DWORD identifier
  90.         LPSTORAGE   m_pIStorage;        //Sub-storage for this page.
  91.         DWORD       m_cOpens;           //Calls to FOpen.
  92.  
  93.         class CPages FAR *m_pPG;        //Pages window
  94.  
  95.         DWORD       m_dwIDNext;
  96.         DWORD       m_cTenants;
  97.         HWND        m_hWndTenantList;   //Listbox that manages our tenant list
  98.  
  99.         UINT        m_iTenantCur;
  100.         LPTENANT    m_pTenantCur;
  101.  
  102.         UINT        m_uHTCode;          //Last hit-test on mouse move.
  103.         UINT        m_uSizingFlags;     //Restrictions on sizing motion.
  104.         BOOL        m_fTracking;        //Tracking resize?
  105.         RECTL       m_rclOrg;           //Original before tracking
  106.         RECTL       m_rcl;              //Tracking rectangle.
  107.         RECTL       m_rclBounds;        //Boundaries for size tracking.
  108.         HDC         m_hDC;              //Tracking hDC.
  109.  
  110.     protected:
  111.         BOOL         FTenantGet(UINT, LPTENANT FAR *, BOOL);
  112.         BOOL         FTenantAdd(UINT, DWORD, LPTENANT FAR *);
  113.         LPDATAOBJECT TransferObjectCreate(LPPOINTL);
  114.  
  115.         //PAGEMOUS.CPP
  116.         //CHAPTER9MOD
  117.         BOOL         FSelectTenantAtPoint(UINT, UINT);
  118.         //End CHAPTER9MOD
  119.  
  120.         UINT         TenantFromPoint(UINT, UINT, LPTENANT FAR *);
  121.         BOOL         DragDrop(UINT, UINT, UINT);
  122.  
  123.  
  124.  
  125.     public:
  126.         CPage(DWORD, HWND, class CPages FAR *);
  127.         ~CPage(void);
  128.  
  129.         DWORD       GetID(void);
  130.         BOOL        FOpen(LPSTORAGE);
  131.         void        Close(BOOL);
  132.         BOOL        Update(void);
  133.         void        Destroy(LPSTORAGE);
  134.         UINT        GetStorageName(LPSTR);
  135.  
  136.         void        Draw(HDC, int, int, BOOL, BOOL);
  137.  
  138.         BOOL        TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
  139.                         , LPPATRONOBJECT, DWORD);
  140.         BOOL        TenantDestroy(void);
  141.         BOOL        TenantClip(BOOL);
  142.         BOOL        FQueryObjectSelected(HMENU);
  143.         //CHAPTER9MOD
  144.         void        ActivateObject(UINT);
  145.         void        NotifyTenantsOfRename(LPSTR, LPVOID);
  146.  
  147.         BOOL        OnRightDown(UINT, UINT, UINT);
  148.         //End CHAPTER9MOD
  149.  
  150.         //PAGEMOUSE.CPP
  151.         BOOL        OnLeftDown(UINT, UINT, UINT);
  152.         BOOL        OnLeftDoubleClick(UINT, UINT, UINT);
  153.         BOOL        OnLeftUp(UINT, UINT, UINT);
  154.         void        OnNCHitTest(UINT, UINT);
  155.         BOOL        OnSetCursor(UINT);
  156.         void        OnMouseMove(UINT, int, int);
  157.     };
  158.  
  159. typedef CPage FAR * LPPAGE;
  160.  
  161.  
  162.  
  163. /*
  164.  * Structures to save with the document describing the device
  165.  * configuration and pages that we have.  This is followed by
  166.  * a list of DWORD IDs for the individual pages.
  167.  */
  168.  
  169. typedef struct __far tagDEVICECONFIG
  170.     {
  171.     DEVMODE     dm;
  172.     char        szDriver[CCHDEVICENAME];
  173.     char        szDevice[CCHDEVICENAME];
  174.     char        szPort[CCHDEVICENAME];
  175.     } DEVICECONFIG, FAR * LPDEVICECONFIG;
  176.  
  177.  
  178. typedef struct __far tagPAGELIST
  179.     {
  180.     DWORD       cPages;
  181.     DWORD       iPageCur;
  182.     DWORD       dwIDNext;
  183.     } PAGELIST, FAR *LPPAGELIST;
  184.  
  185.  
  186. //PAGEWIN.CPP
  187. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  188. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  189. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  190. void                        RectConvertMappings(LPRECT, HDC, BOOL);
  191.  
  192.  
  193.  
  194. class __far CPages : public CWindow
  195.     {
  196.     friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  197.     friend BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  198.  
  199.     friend class CPage;
  200.     friend class CTenant;
  201.     friend class CDropTarget;
  202.     friend class CImpIAdviseSink;
  203.  
  204.     protected:
  205.         LPPAGE      m_pPageCur;             //Current page we're viewing
  206.         UINT        m_iPageCur;
  207.         UINT        m_cPages;               //Number of pages
  208.  
  209.         HWND        m_hWndPageList;         //Listbox that manages our page list
  210.         HFONT       m_hFont;                //Page font.
  211.         BOOL        m_fSystemFont;          //Is m_hFont system object?
  212.  
  213.         UINT        m_cx;                   //Usable page size in LOMETRIC
  214.         UINT        m_cy;
  215.  
  216.         UINT        m_xMarginLeft;          //Unusable page margins, LOMETRIC
  217.         UINT        m_xMarginRight;
  218.         UINT        m_yMarginTop;
  219.         UINT        m_yMarginBottom;
  220.  
  221.         UINT        m_xPos;                 //Current viewport scroll position.
  222.         UINT        m_yPos;                 //both in *PIXELS*
  223.  
  224.         DWORD       m_dwIDNext;             //Next ID for a page.
  225.         LPSTORAGE   m_pIStorage;            //Root storage of document.
  226.  
  227.         UINT        m_cf;                   //Application clipboard format.
  228.         BOOL        m_fDirty;
  229.  
  230.         BOOL        m_fDragSource;          //Drag-drop source==target
  231.         BOOL        m_fMoveInPage;          //Only moving in same page
  232.         POINTL      m_ptDrop;               //Where to move object to.
  233.  
  234.         BOOL        m_fDragRectShown;       //Is there a rect on the screen?
  235.         UINT        m_uScrollInset;         //Hit-test region for drag-drop
  236.         UINT        m_uScrollDelay;         //Time to wait before repeat
  237.         DWORD       m_dwTimeLast;           //Ticks on last DragOver
  238.         UINT        m_uHScrollCode;         //Left or right on scroll repeat?
  239.         UINT        m_uVScrollCode;         //Up or down on scroll repeat?
  240.         UINT        m_uLastTest;            //Last from UTestDroppablePoint
  241.  
  242.     private:
  243.         void      Draw(HDC, BOOL, BOOL);
  244.         void      UpdateScrollRanges(void);
  245.         BOOL      ConfigureForDevice(void);
  246.         BOOL      FPageGet(UINT, LPPAGE FAR *, BOOL);
  247.         BOOL      FPageAdd(UINT, DWORD, BOOL);
  248.  
  249.         void      CalcBoundingRect(LPRECT, BOOL);
  250.  
  251.